Skip to main content
POST
/
api
/
auth
/
registro
Register
curl --request POST \
  --url https://api.example.com/api/auth/registro \
  --header 'Content-Type: application/json' \
  --data '
{
  "username": "<string>",
  "nombre": "<string>",
  "apellidos": "<string>",
  "email": {},
  "password": "<string>",
  "fecha_nacimiento": "<string>",
  "direccion_envio": "<string>",
  "rol": "<string>",
  "activo": true,
  "usuario_id": 123
}
'
{
  "200": {},
  "400": {},
  "token": "<string>",
  "tipo": "<string>"
}

Request

Create a new user account with complete profile information. Returns a JWT token upon successful registration.

Body Parameters

username
string
required
Unique username for the account
nombre
string
required
User’s first name
apellidos
string
required
User’s last name(s)
email
object
required
User’s email address as an Email value object. In JSON, provide as a string or object with value property.Validation: Must be a valid email format
password
string
required
User’s password. Will be encrypted before storage.Validation: Should meet security requirements
fecha_nacimiento
string
required
User’s date of birth in ISO 8601 format (YYYY-MM-DD)Example: “1990-01-15”
direccion_envio
string
required
Shipping address for orders
rol
string
required
User role in the systemAllowed values: ADMIN, CLIENTEDefault: CLIENTE (for customer registrations)
activo
boolean
Whether the account is activeDefault: true
usuario_id
integer
User ID (auto-generated, typically not provided during registration)

Request Example

curl -X POST http://localhost:8080/api/auth/registro \
  -H "Content-Type: application/json" \
  -d '{
    "username": "johndoe",
    "nombre": "John",
    "apellidos": "Doe",
    "email": "john.doe@example.com",
    "password": "securePassword123",
    "fecha_nacimiento": "1990-01-15",
    "direccion_envio": "123 Main St, Madrid, Spain",
    "rol": "CLIENTE",
    "activo": true
  }'
{
  "username": "johndoe",
  "nombre": "John",
  "apellidos": "Doe",
  "email": "john.doe@example.com",
  "password": "securePassword123",
  "fecha_nacimiento": "1990-01-15",
  "direccion_envio": "123 Main St, Madrid, Spain",
  "rol": "CLIENTE",
  "activo": true
}

Response

token
string
JWT authentication token for the newly created user
tipo
string
Token type (always “Bearer”)

Response Example

{
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "tipo": "Bearer"
}

Status Codes

200
OK
User successfully registered. Returns JWT token.
400
Bad Request
Invalid request data. Possible causes:
  • Missing required fields
  • Invalid email format
  • Username or email already exists
  • Invalid date format for fecha_nacimiento
  • Invalid role value (must be ADMIN or CLIENTE)

Validation Rules

  • email: Must be a valid email format and unique in the system
  • username: Must be unique in the system
  • password: Stored encrypted using BCrypt password encoder
  • fecha_nacimiento: Must be in ISO 8601 date format (YYYY-MM-DD)
  • rol: Must be either ADMIN or CLIENTE
  • All required fields: Must be provided and not null

Usage

After successful registration, the user is automatically authenticated and can use the returned token:
curl -X GET http://localhost:8080/api/resource \
  -H "Authorization: Bearer YOUR_TOKEN_HERE"